

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://img.mkerosene.cn/touxiang.jpg">
  <link rel="icon" href="https://img.mkerosene.cn/touxiang.jpg">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Kerosene W">
  <meta name="keywords" content="">
  
    <meta name="description" content="基础指令1.#ls12345ls #列出当前工作目录下的所有文件&#x2F;文件夹的名称ls 路径 #列出指定路径下的所有文件&#x2F;文件夹的名称ls -l 路径 #以详细列表形式展示指定路径下文件&#x2F;文件夹ls -la 路径 #&quot;-l&quot;显示所有文件&#x2F;文件夹,包含隐藏文件(.xxx)ls -lh 路径 #列出指定路径下文件&#x2F;文件夹，以可读性较高的文件大小单位显示   相对路径：当前工作路径 #”">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux指令">
<meta property="og:url" content="http://example.com/2020/10/28/Linux%E5%91%BD%E4%BB%A4/index.html">
<meta property="og:site_name" content="追求源于热爱">
<meta property="og:description" content="基础指令1.#ls12345ls #列出当前工作目录下的所有文件&#x2F;文件夹的名称ls 路径 #列出指定路径下的所有文件&#x2F;文件夹的名称ls -l 路径 #以详细列表形式展示指定路径下文件&#x2F;文件夹ls -la 路径 #&quot;-l&quot;显示所有文件&#x2F;文件夹,包含隐藏文件(.xxx)ls -lh 路径 #列出指定路径下文件&#x2F;文件夹，以可读性较高的文件大小单位显示   相对路径：当前工作路径 #”">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img.mkerosene.cn/bg1.jpeg">
<meta property="article:published_time" content="2020-10-27T21:54:11.000Z">
<meta property="article:modified_time" content="2021-10-15T05:24:28.844Z">
<meta property="article:author" content="Kerosene W">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://img.mkerosene.cn/bg1.jpeg">
  
  
  <title>Linux指令 - 追求源于热爱</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.8.13","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":"❡"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"https://img.mkerosene.cn/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":"FI1uAFAYz0Q3MPDiORqd0JAN-gzGzoHsz","app_key":"EhKAjMe3bmq0WLTSgktGg2OC","server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>mKerosene</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('https://img.mkerosene.cn/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="Notes about Linux construction......">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-10-28 05:54" pubdate>
        2020年10月28日 凌晨
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      4.4k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      14 分钟
    </span>
  

  
  
    
      <!-- LeanCloud 统计文章PV -->
      <span id="leancloud-page-views-container" class="post-meta" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="leancloud-page-views"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Notes about Linux construction......</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：1 年前
                
              </p>
            
            <div class="markdown-body">
              <h1 id="基础指令"><a href="#基础指令" class="headerlink" title="基础指令"></a>基础指令</h1><h2 id="1-ls"><a href="#1-ls" class="headerlink" title="1.#ls"></a>1.<code>#ls</code></h2><figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs jboss-cli"><span class="hljs-keyword">ls</span> <span class="hljs-comment">#列出当前工作目录下的所有文件/文件夹的名称</span><br><span class="hljs-keyword">ls</span> 路径 <span class="hljs-comment">#列出指定路径下的所有文件/文件夹的名称</span><br><span class="hljs-keyword">ls</span> -l 路径 <span class="hljs-comment">#以详细列表形式展示指定路径下文件/文件夹</span><br><span class="hljs-keyword">ls</span> -la 路径 <span class="hljs-comment">#&quot;-l&quot;显示所有文件/文件夹,包含隐藏文件(.xxx)</span><br><span class="hljs-keyword">ls</span> -lh 路径 <span class="hljs-comment">#列出指定路径下文件/文件夹，以可读性较高的文件大小单位显示</span><br></code></pre></td></tr></table></figure>

<ul>
<li>相对路径：当前工作路径 #”./“:当前目录下    “../“:上一级目录下</li>
<li>绝对路径：直接从根路径”/“开始寻找相应路径</li>
<li>ls列出结果颜色说明:蓝色表示文件夹/黑色表示文件/绿色表示拥有所有权限</li>
</ul>
<p><strong><code>-l</code></strong></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BafxZ4"><img src="https://s1.ax1x.com/2020/10/31/BafxZ4.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BafxZ4.png"></a></p>
<p><strong><code>-la</code></strong></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BafjLF"><img src="https://s1.ax1x.com/2020/10/31/BafjLF.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BafjLF.png"></a></p>
<ul>
<li>上述列表第一列指文档类型，”<code>-</code>“表示文件；”<code>d</code>“表示文件夹</li>
<li>隐藏文件格式为.xxx</li>
</ul>
<p><strong><code>-l(a)h</code></strong></p>
<ul>
<li><p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BafXsU"><img src="https://s1.ax1x.com/2020/10/31/BafXsU.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BafXsU.png"></a> </p>
<p>初始大小4.0 k</p>
</li>
</ul>
<hr>
<h2 id="2-pwd"><a href="#2-pwd" class="headerlink" title="2.#pwd"></a>2.<code>#pwd</code></h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">pwd</span> <span class="hljs-comment">#打印当前目录</span><br></code></pre></td></tr></table></figure>



<ul>
<li><p>(print working directory)打印当前工作目录</p>
<p>图5</p>
</li>
</ul>
<hr>
<h2 id="3-cd"><a href="#3-cd" class="headerlink" title="3.#cd"></a>3.<code>#cd</code></h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">cd</span>或者<span class="hljs-built_in">cd</span> ~ <span class="hljs-comment">#切换至当前用户家目录</span><br><span class="hljs-built_in">cd</span> 路径 <span class="hljs-comment">#切换至路径目录</span><br></code></pre></td></tr></table></figure>

<ul>
<li>(change directory)改变目录</li>
</ul>
<p><code>cd/cd ~</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/Bah9iR"><img src="https://s1.ax1x.com/2020/10/31/Bah9iR.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="Bah9iR.png"></a></p>
<p><code>cd 路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahCJ1"><img src="https://s1.ax1x.com/2020/10/31/BahCJ1.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahCJ1.png"></a></p>
<hr>
<h2 id="4-mkdir"><a href="#4-mkdir" class="headerlink" title="4.#mkdir"></a>4.<code>#mkdir</code></h2><figure class="highlight hsp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs hsp"><span class="hljs-keyword">mkdir</span> 路径 <span class="hljs-meta">#路径可以为新文件夹名称，也可包含新文件夹的完整路径</span><br><span class="hljs-keyword">mkdir</span> -p 路径 <span class="hljs-meta">#一次性创建多层新文件夹</span><br><span class="hljs-keyword">mkdir</span> 路径<span class="hljs-number">1</span> 路径<span class="hljs-number">2</span> 路径<span class="hljs-number">3</span> <span class="hljs-meta">#一次性创建多个新文件夹</span><br></code></pre></td></tr></table></figure>

<ul>
<li><p>(make directory)创建目录</p>
</li>
<li><ul>
<li>建成功无提示,可用<code>ls</code>查看</li>
</ul>
</li>
</ul>
<p><code>mkdir  路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahPRx"><img src="https://s1.ax1x.com/2020/10/31/BahPRx.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahPRx.png"></a><code>mkdir -p 路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/Bahiz6"><img src="https://s1.ax1x.com/2020/10/31/Bahiz6.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="Bahiz6.png"></a></p>
<p><code>mkdir 路径1 路径2 路径3</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahkQK"><img src="https://s1.ax1x.com/2020/10/31/BahkQK.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahkQK.png"></a></p>
<hr>
<h2 id="5-touch"><a href="#5-touch" class="headerlink" title="5.#touch"></a>5.<code>#touch</code></h2><figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs apache"><span class="hljs-attribute">touch</span> 文件路径 #创建文件<br><span class="hljs-attribute">touch</span> 路径<span class="hljs-number">1</span> 路径<span class="hljs-number">2</span> 路径<span class="hljs-number">3</span> #一次性创建多个文件(同mkdir)<br></code></pre></td></tr></table></figure>

<ul>
<li>创建文件</li>
</ul>
<p><code>touch 路径1 路径2 路径3</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahAsO"><img src="https://s1.ax1x.com/2020/10/31/BahAsO.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahAsO.png"></a></p>
<hr>
<h2 id="6-cp"><a href="#6-cp" class="headerlink" title="6.#cp"></a>6.<code>#cp</code></h2><figure class="highlight avrasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs avrasm"><span class="hljs-keyword">cp</span> 被复制文档路径 目标路径 <span class="hljs-meta">#复制过程可对新文档重命名</span><br><span class="hljs-keyword">cp</span> -r 被复制文档路径 目标路径 <span class="hljs-meta">#递归复制(赋值文件夹时使用,复制整个文件夹)，否则文件夹将被略过</span><br></code></pre></td></tr></table></figure>

<ul>
<li>(copy复制文件/文件夹)</li>
</ul>
<p><code>cp 被复制文档路径 目标路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahELD"><img src="https://s1.ax1x.com/2020/10/31/BahELD.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahELD.png"></a></p>
<p><code>cp -r 被复制文档路径 目标路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahZee"><img src="https://s1.ax1x.com/2020/10/31/BahZee.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahZee.png"></a></p>
<hr>
<h2 id="7-mv"><a href="#7-mv" class="headerlink" title="7.#mv"></a>7.<code>#mv</code></h2><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">mv</span> 待移动文档路径 目标路径 <span class="hljs-comment">#移动文档到新位置  移动文件夹同，无需-r</span><br><span class="hljs-built_in">mv</span> 原文件路径 重命名后路径（原地移动） <span class="hljs-comment">#重命名</span><br></code></pre></td></tr></table></figure>

<ul>
<li>(move移动/剪切)</li>
</ul>
<p><code>mv 待移动文档路径 目标路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahedH"><img src="https://s1.ax1x.com/2020/10/31/BahedH.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahedH.png"></a></p>
<hr>
<h2 id="8-rm"><a href="#8-rm" class="headerlink" title="8.#rm"></a>8.<code>#rm</code></h2><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">rm</span> 需移除文档路径 <span class="hljs-comment">#移除/删除文档 提示是否删除</span><br><span class="hljs-built_in">rm</span> <span class="hljs-literal">-rf</span> 需移除文档路径 <span class="hljs-comment">#(force强制)无提示 -r同指递归</span><br><span class="hljs-built_in">rm</span> <span class="hljs-literal">-rf</span> 路径<span class="hljs-number">1</span> 路径<span class="hljs-number">2</span> <span class="hljs-comment">#同时删除多个文档    同类名*（通配符，可表示任意字符，一次性删除相同开头的名称）</span><br></code></pre></td></tr></table></figure>

<ul>
<li>(remove,移除、删除)</li>
</ul>
<p><code>rm 需移除文件路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/Bahmod"><img src="https://s1.ax1x.com/2020/10/31/Bahmod.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="Bahmod.png"></a></p>
<p><code>rm -rf 需移除文档路径</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahuFA"><img src="https://s1.ax1x.com/2020/10/31/BahuFA.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahuFA.png"></a></p>
<hr>
<h2 id="9-vim"><a href="#9-vim" class="headerlink" title="9.#vim"></a>9.<code>#vim</code></h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">vim</span> 文件路径 <span class="hljs-comment">#打开一个文件（可以是不存在的文件）</span><br></code></pre></td></tr></table></figure>

<ul>
<li><p>文本编辑器</p>
</li>
<li><p>退出文件：按shift+英文冒号<code>:</code>+<code>q</code>+<code>Enter</code></p>
</li>
</ul>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahMWt"><img src="https://s1.ax1x.com/2020/10/31/BahMWt.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahMWt.png"></a><a target="_blank" rel="noopener" href="https://imgchr.com/i/BahlSP"><img src="https://s1.ax1x.com/2020/10/31/BahlSP.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="BahlSP.png"></a></p>
<hr>
<h2 id="10-gt-gt-gt"><a href="#10-gt-gt-gt" class="headerlink" title="10.#&gt;/&gt;&gt;"></a>10.<code>#&gt;/&gt;&gt;</code></h2><figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs 1c">指令 &gt;/&gt;&gt; 保存到文件路径 <span class="hljs-meta">#输出重定向 </span><br></code></pre></td></tr></table></figure>

<ul>
<li><code>&gt;</code>:覆盖输出，覆盖原文内容</li>
<li><code>&gt;&gt;</code>:追加输出，在原始内容末尾继续添加</li>
</ul>
<ul>
<li>保存命令执行结果到文件，文件可以不存在，不存在则新建</li>
</ul>
<p><code>&gt;/&gt;&gt;</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/Bah1Qf"><img src="https://s1.ax1x.com/2020/10/31/Bah1Qf.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="Bah1Qf.png"></a><a target="_blank" rel="noopener" href="https://imgchr.com/i/Bah8OS"><img src="https://s1.ax1x.com/2020/10/31/Bah8OS.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="Bah8OS.png"></a></p>
<h2 id="11-cat"><a href="#11-cat" class="headerlink" title="11.#cat"></a>11.<code>#cat</code></h2><figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs apache"><span class="hljs-attribute">cat</span> 文件路径<br><span class="hljs-attribute">cat</span> 待合并的文件<span class="hljs-number">1</span> 待合并的文件<span class="hljs-number">2</span>... &gt;合并后文件路径<br></code></pre></td></tr></table></figure>

<ul>
<li>直接打开一个文件(无需退出)</li>
<li>对文件进行合并【配合输出重定向使用】,源文件不会删除</li>
</ul>
<p>····································································································································································</p>
<ul>
<li>选项均可连用，例：-la、 -rf 、-lah</li>
</ul>
<h1 id="进阶指令"><a href="#进阶指令" class="headerlink" title="进阶指令"></a>进阶指令</h1><h2 id="1-df"><a href="#1-df" class="headerlink" title="1.#df"></a>1.<code>#df</code></h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">df</span> -h <span class="hljs-comment">#以较高可读性查看</span><br></code></pre></td></tr></table></figure>

<ul>
<li>查看磁盘空间</li>
</ul>
<p><code>df -h</code></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHqij"><img src="https://s3.ax1x.com/2020/11/20/DMHqij.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHqij.png"></a></p>
<h2 id="2-free"><a href="#2-free" class="headerlink" title="2.#free"></a>2.<code>#free</code></h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">free</span> -m <span class="hljs-comment">#以MB为单位进行查看</span><br></code></pre></td></tr></table></figure>

<ul>
<li>查看内存使用情况</li>
</ul>
<p><code>free -n</code></p>
<ul>
<li><p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMH7dg"><img src="https://s3.ax1x.com/2020/11/20/DMH7dg.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMH7dg.png"></a>剩余真是可用为available</p>
</li>
<li><p>swap用于临时内存，当系统真是内存不够用时可以临时使用磁盘空间来充当内存</p>
</li>
</ul>
<hr>
<h2 id="3-head"><a href="#3-head" class="headerlink" title="3.#head"></a>3.<code>#head</code></h2><figure class="highlight excel"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs excel">head -<span class="hljs-built_in">n</span> 文件路径 #查看一个文件的前<span class="hljs-built_in">n</span>行，默认<span class="hljs-number">10</span>行 [<span class="hljs-built_in">n</span>表示数字]<br></code></pre></td></tr></table></figure>

<h2 id=""><a href="#" class="headerlink" title=""></a><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHHoQ"><img src="https://s3.ax1x.com/2020/11/20/DMHHoQ.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHHoQ.png"></a></h2><h2 id="4-tail"><a href="#4-tail" class="headerlink" title="4.#tail"></a>4.<code>#tail</code></h2><figure class="highlight excel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs excel">tail -<span class="hljs-built_in">n</span> 文件路径 #查看一个文件的末<span class="hljs-built_in">n</span>行，默认<span class="hljs-number">10</span>行 [<span class="hljs-built_in">n</span>表示数字]<br>tail -f 文件路径 #查看一个文件的动态变化，配合输出重定向，按q键退出<br></code></pre></td></tr></table></figure>

<h2 id="-1"><a href="#-1" class="headerlink" title=""></a><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHTeS"><img src="https://s3.ax1x.com/2020/11/20/DMHTeS.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHTeS.png"></a></h2><h2 id="5-less"><a href="#5-less" class="headerlink" title="5.#less"></a>5.<code>#less</code></h2><figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-keyword">less</span> 文件路径 <span class="hljs-comment">#，查看文件,以较少内容输出，配合辅助功能键(数字+回车,空格翻页，上下键或回车换行)查看更多，q退出</span><br></code></pre></td></tr></table></figure>



<h2 id="6-wc"><a href="#6-wc" class="headerlink" title="6.#wc"></a>6.<code>#wc</code></h2><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">wc -<span class="hljs-keyword">lwcm </span>文件路径 <span class="hljs-comment">#统计文件信息(-l行数，-w单词数，-c字节数,-m字符数)</span><br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHIL8"><img src="https://s3.ax1x.com/2020/11/20/DMHIL8.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHIL8.png"></a></p>
<hr>
<h2 id="7-date"><a href="#7-date" class="headerlink" title="7.#date"></a>7.<code>#date</code></h2><ul>
<li>获取当前时间</li>
</ul>
<figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs apache"><span class="hljs-attribute">date</span> #Tue Nov <span class="hljs-number">10</span> <span class="hljs-number">00</span>:<span class="hljs-number">02</span>:<span class="hljs-number">57</span> CST <span class="hljs-number">2020</span> 显示时间CST(当地时间) <br><span class="hljs-attribute">date</span> +%F #<span class="hljs-number">2020</span>-<span class="hljs-number">11</span>-<span class="hljs-number">10</span>(等价于#date <span class="hljs-string">&quot;%Y-%m-%d&quot;</span>)<br><span class="hljs-attribute">date</span> <span class="hljs-string">&quot;+%F %T&quot;</span> #<span class="hljs-number">2020</span>-<span class="hljs-number">11</span>-<span class="hljs-number">10</span> <span class="hljs-number">00</span>:<span class="hljs-number">02</span>:<span class="hljs-number">57</span>(等价于#date <span class="hljs-string">&quot;+%Y-%m-%d %H:%M:%S&quot;</span>)     <br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHLJs"><img src="https://s3.ax1x.com/2020/11/20/DMHLJs.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHLJs.png"></a></p>
<ul>
<li>获取之前或之后时间</li>
</ul>
<figure class="highlight perl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs perl">date -d <span class="hljs-string">&quot;-1year&quot;</span> <span class="hljs-string">&quot;+%Y-%m-%d %H:%M:%S&quot;</span>一年前时间<br>date -d <span class="hljs-string">&quot;+1year&quot;</span> <span class="hljs-string">&quot;+%Y-%m-%d %H:%M:%S&quot;</span>一年后时间<br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHOWn"><img src="https://s3.ax1x.com/2020/11/20/DMHOWn.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHOWn.png"></a></p>
<ul>
<li><p>单位的可选值：day、month、year无需考虑复数</p>
<ul>
<li>%m、%d、%H、%M、%S均带前导0</li>
</ul>
</li>
</ul>
<hr>
<h2 id="8-cal"><a href="#8-cal" class="headerlink" title="8.#cal"></a>8.#<code>cal</code></h2><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs awk">cal <span class="hljs-comment">#直接输出当前月份日历(等价于#cal -1)</span><br>cal -<span class="hljs-number">3</span> <span class="hljs-comment">#上月+本月+下月</span><br>cal -y2020 <span class="hljs-comment">#输出某年日历</span><br>*cal -s<span class="hljs-regexp">/-m #周日为第一天/</span>周一为第一天<br></code></pre></td></tr></table></figure>

<ul>
<li><p>操作日历</p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHXzq"><img src="https://s3.ax1x.com/2020/11/20/DMHXzq.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHXzq.png" style="zoom:80%;" /></a><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHxyV"><img src="https://s3.ax1x.com/2020/11/20/DMHxyV.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHxyV.png" style="zoom:80%;" /></a></p>
</li>
</ul>
<hr>
<h2 id="9-clear-ctrl-L"><a href="#9-clear-ctrl-L" class="headerlink" title="9.#clear/ctrl + L"></a>9.#<code>clear/ctrl + L</code></h2><figure class="highlight isbl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs isbl"><span class="hljs-variable">clear</span><br><span class="hljs-variable">ctrl</span>+<span class="hljs-function"><span class="hljs-title">L</span>(快捷键)</span><br></code></pre></td></tr></table></figure>

<ul>
<li>清除终端中已经存在的命令和结果</li>
<li>并非清除信息，而是隐藏至上方，可滚动查看(不同于Windows中<code>cls</code>清屏)</li>
</ul>
<hr>
<h2 id="10-管道"><a href="#10-管道" class="headerlink" title="10.管道"></a>10.管道</h2><ul>
<li><p>管道符：<code>|</code></p>
</li>
<li><p>用于”过滤”，”特殊”，”扩展处理”,不能单独使用，配合其他命令，起辅助作用</p>
</li>
</ul>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs jboss-cli">命令* | grep 过滤内容 <span class="hljs-comment">#过滤：所配合的命令必须有输出来作为管道的输入</span><br><span class="hljs-keyword">ls</span> |wc -l <span class="hljs-comment">#统计文档总个数(扩展处理)</span><br></code></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHvQ0"><img src="https://s3.ax1x.com/2020/11/20/DMHvQ0.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHvQ0.png"></a></p>
<hr>
<h1 id="高级指令"><a href="#高级指令" class="headerlink" title="高级指令"></a>高级指令</h1><h2 id="1-hostname"><a href="#1-hostname" class="headerlink" title="1.#hostname"></a>1.#<code>hostname</code></h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">hostname</span> <span class="hljs-comment">#输出主机名</span><br>hostname -f <span class="hljs-comment">#输出当前主机名中的FQDN(全限定域名)</span><br></code></pre></td></tr></table></figure>

<ul>
<li>操作服务器的主机名</li>
</ul>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMHzLT"><img src="https://s3.ax1x.com/2020/11/20/DMHzLT.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMHzLT.png"></a></p>
<h2 id="2-id"><a href="#2-id" class="headerlink" title="2.#id"></a>2.#<code>id</code></h2><figure class="highlight applescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs applescript"><span class="hljs-built_in">id</span><br><span class="hljs-built_in">id</span> 用户名 <span class="hljs-comment">#指定用户</span><br></code></pre></td></tr></table></figure>

<ul>
<li>查看用户基本信息(用户id、用户组id、附加组id)，不指定默认当前用户</li>
</ul>
<hr>
<h2 id="3-whoami"><a href="#3-whoami" class="headerlink" title="3.#whoami"></a>3.#<code>whoami</code></h2><ul>
<li>“我是谁?”显示当前登录的用户名，一般用于shell脚本</li>
</ul>
<hr>
<h2 id="4-ps-ef"><a href="#4-ps-ef" class="headerlink" title="4.#ps -ef"></a>4.#<code>ps -ef</code></h2><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">ps -ef<span class="hljs-regexp">/-e/</span>-f<br></code></pre></td></tr></table></figure>

<ul>
<li>查看服务器进程信息</li>
<li><code>-e</code>列出全部进程</li>
<li><code>-f</code>列出全部的列(显示全字段)</li>
</ul>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMbpeU"><img src="https://s3.ax1x.com/2020/11/20/DMbpeU.md.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMbpeU.md.png"></a></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/DMbiFJ"><img src="https://s3.ax1x.com/2020/11/20/DMbiFJ.md.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="DMbiFJ.md.png"></a></p>
<ul>
<li>常配合过滤使用,搜索结果为两个才是有在运行的目标进程</li>
</ul>
<p><code>ps -ef|grep 进行名称</code></p>
<hr>
<h2 id="5-top"><a href="#5-top" class="headerlink" title="5.#top"></a>5.#<code>top</code></h2><ul>
<li>查看进程占用资源(动态显示)，按q退出</li>
</ul>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/rhHR1K"><img src="https://s3.ax1x.com/2020/12/26/rhHR1K.md.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="rhHR1K.md.png"></a></p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/rhHfXD"><img src="https://s3.ax1x.com/2020/12/26/rhHfXD.md.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="rhHfXD.md.png"></a></p>
<p>三种内存释义</p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/rhH4ne"><img src="https://s3.ax1x.com/2020/12/26/rhH4ne.md.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="rhH4ne.md.png"></a></p>
<ul>
<li><p>top运行中按下<code>M</code>(MEM)结果按内存降序排列</p>
<p>​                          <code>P</code>结果按CPU使用率降序排列</p>
<p>​                         <code>1</code>展开或收起各个CPU的详细信息</p>
</li>
</ul>
<h2 id="6-du-sh"><a href="#6-du-sh" class="headerlink" title="6.#du -sh"></a>6.#<code>du -sh</code></h2><ul>
<li>查看目录的真实大小</li>
</ul>
<figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stata">du- <span class="hljs-keyword">sh</span> /路径<br></code></pre></td></tr></table></figure>

<p> -s  : summaries,只显示汇总的大小<br> -h : 表示以较高可读性的形式显示</p>
<p><a target="_blank" rel="noopener" href="https://imgchr.com/i/rhH2p6"><img src="https://s3.ax1x.com/2020/12/26/rhH2p6.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="rhH2p6.png"></a></p>
<h2 id="7-find"><a href="#7-find" class="headerlink" title="7.#find"></a>7.#<code>find</code></h2><ul>
<li>用于查找文件(参数55个之多)</li>
</ul>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs routeros"><span class="hljs-builtin-name">find</span> 路径范围 选项 选项的值<br></code></pre></td></tr></table></figure>

<p>选项：</p>
<p>​        -name：按照文档名称进行搜索（支持模糊搜索）</p>
<p>​        -type：按照文档类型进行搜索</p>
<p>​                    文档类型：“-”表示文件（find中用f替换），“d”表示文件夹</p>
<h2 id="8-service"><a href="#8-service" class="headerlink" title="8.#service"></a>8.#<code>service</code></h2><p>用于控制一些软件服务的启动 /停止/重启</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">service 服务名 start<span class="hljs-regexp">/stop/</span>restart<br></code></pre></td></tr></table></figure>

<ul>
<li>启动Apache <code>service httpd start</code></li>
</ul>
<h2 id="9-kill"><a href="#9-kill" class="headerlink" title="9.#kill"></a>9.#<code>kill</code></h2><ul>
<li>用于杀死进程</li>
</ul>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">kill</span> 进程PID		(需配合<span class="hljs-built_in">ps</span>使用)<br></code></pre></td></tr></table></figure>

<img src="https://img.mkerosene.cn/2021-04-16_172456.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="2021-04-16_172456" style="zoom: 80%;" />

<ul>
<li>或选择<code>killall 进程名称</code>，无需使用ps查看</li>
</ul>
<h2 id="10-ifconfig"><a href="#10-ifconfig" class="headerlink" title="10.#ifconfig"></a>10.#<code>ifconfig</code></h2><ul>
<li>查看网卡</li>
</ul>
<img src="https://img.mkerosene.cn/2021-04-16_175927.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="2021-04-16_175927" style="zoom:80%;" />

<ul>
<li>eth0表示Linux的一个网卡，lo(loop，本地回环网卡，ip：<code>127.0.0.1</code>)</li>
</ul>
<h2 id="11-reboot"><a href="#11-reboot" class="headerlink" title="11.#reboot"></a>11.#<code>reboot</code></h2><ul>
<li>重启计算机</li>
</ul>
<figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs 1c"><span class="hljs-meta">#reboot		<span class="hljs-comment">//重启</span></span><br><span class="hljs-meta">#reboot -w	<span class="hljs-comment">//模拟重启(只写开机与关机的日志)</span></span><br></code></pre></td></tr></table></figure>

<h2 id="12-shutdown"><a href="#12-shutdown" class="headerlink" title="12.#shutdown"></a>12.#<code>shutdown</code></h2><ul>
<li>关机        //慎用，远程直接掉线</li>
</ul>
<figure class="highlight arduino"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs arduino"><span class="hljs-meta">#shutdown -h now		<span class="hljs-comment">//立即关机</span></span><br><span class="hljs-meta">#shutdown -h 18:18 <span class="hljs-meta-string">&quot;关机提示&quot;</span>		<span class="hljs-comment">//18:18关机(ctrl+c取消定时关机CentOS7.0之前)</span></span><br><span class="hljs-meta">#shutdown -c			<span class="hljs-comment">//取消关机(CentOS7.0及以后)</span></span><br></code></pre></td></tr></table></figure>

<figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs vala">其他关机指令<br><span class="hljs-meta">#init 0</span><br><span class="hljs-meta">#halt</span><br><span class="hljs-meta">#poweroff</span><br></code></pre></td></tr></table></figure>

<h2 id="13-uptime"><a href="#13-uptime" class="headerlink" title="13.#uptime"></a>13.#<code>uptime</code></h2><ul>
<li>输出计算机的持续在线时间</li>
</ul>
<figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs vala"><span class="hljs-meta">#uptime</span><br></code></pre></td></tr></table></figure>

<img src="https://img.mkerosene.cn/2021-04-16_182137.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="2021-04-16_182137" style="zoom:99%;" />

<ul>
<li>load average: 负载，显示最近1分钟、5分钟和15分钟的系统平均负载</li>
</ul>
<h2 id="14-uname"><a href="#14-uname" class="headerlink" title="14.#uname"></a>14.#<code>uname</code></h2><ul>
<li>获取计算机操作系统相关信息</li>
</ul>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs stylus"><span class="hljs-selector-id">#uname</span>	<span class="hljs-comment">//获取操作系统类型</span><br><span class="hljs-selector-id">#uname</span> -<span class="hljs-selector-tag">a</span>	<span class="hljs-comment">//all,表示获取全部系统的信息（类型，全部主机名，内核版本，发布时间，开源计划）</span><br></code></pre></td></tr></table></figure>

<p><img src="https://img.mkerosene.cn/2021-04-18_091037.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="2021-04-18_091037"></p>
<h2 id="15-netstat-tnlp"><a href="#15-netstat-tnlp" class="headerlink" title="15.#netstat -tnlp"></a>15.#<code>netstat -tnlp</code></h2><ul>
<li>查看网络连接状态</li>
</ul>
<figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs vala"><span class="hljs-meta">#netstat -tnlp</span><br></code></pre></td></tr></table></figure>

<ul>
<li>选项说明：<ul>
<li>-t：只列出tcp协议的链接</li>
<li>-n：将字母组合转化成IP地址，把协议转化为端口号来显示</li>
<li>-l：过滤出“state（状态）”列中值为LISTEN（监听）的链接</li>
<li>-p：显示发起连接的进程PID和进程名称</li>
</ul>
</li>
</ul>
<p><img src="https://img.mkerosene.cn/2021-04-18_092610.png" srcset="https://img.mkerosene.cn/loading.gif" lazyload alt="2021-04-18_092610"></p>
<h2 id="16-man"><a href="#16-man" class="headerlink" title="16.#man"></a>16.#<code>man</code></h2><ul>
<li>manual，手册（包含了Linux中全部命令手册，英文）</li>
</ul>
<figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs 1c"><span class="hljs-meta">#man 命令	<span class="hljs-comment">//按q退出</span></span><br></code></pre></td></tr></table></figure>

<hr>
<hr>
<h1 id="练习题"><a href="#练习题" class="headerlink" title="练习题"></a>练习题</h1><ul>
<li>如何通过命令行重启linux操作系统？    #reboot</li>
<li>如何在命令行中快速删除光标前、后的(全部)内容？<ul>
<li>前：ctrl + u</li>
<li>后：ctrl + k</li>
</ul>
</li>
<li>如何删除/temp下所有A开头的文件？<ul>
<li>#rm -f /tmp/A*</li>
</ul>
</li>
<li>系统重要文件需要备份，如何把/etc/passwd备份到/tmp目录下？<ul>
<li>#cp /etc/passwd /tmp</li>
</ul>
</li>
<li>如何查看系统最后创建的3个用户？<ul>
<li>#tail -3 /etc/passwd</li>
</ul>
</li>
<li>什么命令可以统计当前系统中一共多少用户？<ul>
<li>#wc -l /etc/passwd</li>
<li>#cat /etc/passwd | wc -l</li>
</ul>
</li>
<li>如何创建/tmp/test.conf文件？<ul>
<li>#touch /tmp/test.conf</li>
</ul>
</li>
<li>如何通过vim编辑打开/tmp/test.conf?<ul>
<li>#vim /tmp/test.conf</li>
</ul>
</li>
<li>如何查看/etc/passwd的头3行和尾3行？<ul>
<li>#head -3 /etc/passwd</li>
<li>#tail -3 /etc/passwd</li>
</ul>
</li>
<li>如何一次性创建目录/text/1/2/3/4?<ul>
<li>#mkdir -p /text/1/2/3/4</li>
</ul>
</li>
<li>如何快速返回当前账户的家目录？<ul>
<li>#cd ~</li>
</ul>
</li>
<li>如何查看/etc所占的磁盘空间？<ul>
<li>#du -sh /etc/</li>
</ul>
</li>
<li>如何删除/tmp下所有的文件？<ul>
<li>#rm -rf /tmp/*            (不包含本身，需要加*)</li>
</ul>
</li>
<li>尝试启动Apache服务，并检查是否启动成功。<ul>
<li>#service httd start</li>
<li>#ps -ef | grep httd</li>
</ul>
</li>
<li>使用已学命令杀死Apache进程。<ul>
<li>#killall httd</li>
</ul>
</li>
</ul>
<p>halt：内存</p>
<p>Linux命令大全<a target="_blank" rel="noopener" href="https://man.linuxde.net/">https://man.linuxde.net</a></p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/Cyber-Security/">Cyber-Security</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Linux/">Linux</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/10/31/bandit%E9%9D%B6%E5%9C%BAwp/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">bandit靶场wp(持续更新中)</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/10/23/Linux%E5%AE%89%E8%A3%85/">
                        <span class="hidden-mobile">Kali Linux安装保姆级教程</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments" lazyload>
                
                  
                
                
  <div id="twikoo"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#comments', function() {
      Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/twikoo@1/dist/twikoo.all.min.js', function() {
        var options = Object.assign(
          {"envId":"blog-3gentarg3e6a1b5e","region":"ap-shanghai","path":"window.location.pathname"},
          {
            el: '#twikoo',
            path: 'window.location.pathname',
            onCommentLoaded: function() {
              Fluid.plugins.initFancyBox('#twikoo .tk-content img:not(.tk-owo-emotion)');
            }
          }
        )
        twikoo.init(options)
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <div class="copyright">&copy;2020 - 2021 By Kerosene.W</div> <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- LeanCloud 统计PV -->
        <span id="leancloud-site-pv-container" style="display: none">
            总访问量 
            <span id="leancloud-site-pv"></span>
             次
          </span>
      
      
        <!-- LeanCloud 统计UV -->
        <span id="leancloud-site-uv-container" style="display: none">
            总访客数 
            <span id="leancloud-site-uv"></span>
             人
          </span>
      

    
  </div>


  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  




  <script defer src="/js/leancloud.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>












  

  

  

  

  

  





<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
